<template>
	<view class="trade-buy">
		<view class="trade-buy-list">
			<block v-for="(item, index) in buys" :key="index">
				<view class="trade-titel">{{ item.time }}</view>
				<view
					class="tbl tbl-item van-hairline--top-bottom"
					v-for="(key, index2) in item.info"
					:key="index2"
				>
					<view class="tbl-item-info">
						<view class="tbl-item-info-id">
							<view class="tbl-item-info-icon iconfont icontouzi color4"></view>
						</view>
						<view class="tbl-item-info-sum">
							<text>投入锁仓</text>
							<text class="time">{{ key.time }}</text>
						</view>
					</view>
					<view class="tbl-item-info-sum right">
						<text class="color4 sum">{{ key.val }}</text>
						<text>LAB锁仓</text>
					</view>
				</view>
			</block>
			<loadding-more 
			:noData="noData" 
			:loadEnd="loadEnd"
			@LoadEmitd="getLABredInvest"
			></loadding-more>
		</view>
	</view>
</template>
<script>
import { mapActions, mapGetters } from 'vuex';
import LoaddingMore from '../../../components/loadding-more.vue';
export default {
	props: {
		activered: {
			type: Number
		}
	},
	components: {
		LoaddingMore
	},
	data() {
		return {
			buys: [],
			loadEnd: false,
			noData: false
		};
	},
	onShow() {
		this.getLABredInvest()
	},
	onReachBottom() {
	},
	watch: {
		activered(val) {
			if (this.buys.length >= 1) return;
			this.getLABredInvest();
		}
	},
	computed: {
		...mapGetters({
			userInfo: 'getUserInfo'
		})
	},
	methods: {
		...mapActions(['setTRDetails']),
		goDetails(key) {
			this.setTRDetails(key);
			uni.navigateTo({
				url: '/pages/bookkeeping/record/details?type=1'
			});
		},
		getLABredInvest (ctime) {
			if (this.activered !== 0) return false
			this.$http.getLABredInvest({uid: this.userInfo.id,ctime: ctime || ''}).then(e => {
				let arr = []
				const data = e.data
				if (data) {
					 for(const i in data) {
					  arr.push({
						  time: i,
						  info: data[i]
					  })
					}
					this.buys = arr
				}
				this.noData = false
				this.loadEnd = true
			}).catch(err => {
				this.noData = true
			})
		}
	}
};
</script>
<style scoped lang="scss">
@import '../../../common/integral-trade.scss';

.trade-titel {
	display: flex;
	padding: 0 30upx;
	height: 40px;
	line-height: 40px;
	color: #9b9b9b;
	background-color: #f2f2f2;
	text {
		display: block;
		min-width: 300upx;
	}
}

.tbl-item-info-sum {
	.sum {
		font-size: 36upx;
	}
	&.right {
		font-size: 28upx;
		text-align: right;
		line-height: 1.2;
	}
	.time {
		line-height: 1.2;
		font-size: 22upx;
		color: #9b9b9b;
	}
}
.trade-buy-list {
	.tbl-item {
		margin-bottom: 0;
	}
}
</style>
